package com.example.demo.sys.controller;

import com.example.demo.sys.common.BeanValidator;
import com.example.demo.sys.model.ValidationDemo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.Map;

/**
 * Created by 蔡超 on 2018/10/6.
 */
@RestController
@Slf4j
public class ValidationController {

    @RequestMapping("/validate")
    private String validate(ValidationDemo validationDemo){
        Map<String,String> map = BeanValidator.validateObject(validationDemo);
        if(!map.isEmpty()){
            for (Map.Entry<String,String> entry :map.entrySet()){
                log.info("{}->{}",entry.getKey(),entry.getValue());
            }
        }
        return "validate success";
    }

}
